package org.example.chapter2;

import rx.Observable;
import rx.functions.Action1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Demo2_1_3 {
    public static void main(String[] args) {
        Integer[] arrays = new Integer[]{0,1,2,3,4,5};
        Observable.from(arrays).subscribe(new Action1<Integer>() {
            @Override
            public void call(Integer integer) {
                System.err.println("From Array:" + integer);
            }
        });

        List<Integer> list = Arrays.asList(arrays);
        Observable.from(list).subscribe(new Action1<Integer>() {
            @Override
            public void call(Integer integer) {
                System.err.println("From list:" + integer);
            }
        });

        Observable.just(arrays).subscribe(new Action1<Integer[]>() {
            @Override
            public void call(Integer[] integers) {
                String str = Arrays.stream(integers).map(i -> i.toString()).collect(Collectors.joining(","));
                System.err.println(str);
            }
        });
    }
}
